package com.pda.yuanjing.dialog.subcode;

import android.app.Dialog;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.pda.yuanjing.PDApp;
import com.pda.yuanjing.R;
import com.pda.yuanjing.beanout.GYSBeanOut;
import com.pda.yuanjing.beanout.NoBillBeanOut;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;
import java.util.List;

public class SubCodeDialog extends Dialog {
    private String TAG = "SubCodeDialog";
    private ImageView ivexit;
    private SmartRefreshLayout refreshLayout;
    private ListView listView;
    private PriorityListener listener;
    private Context mContext;
    private ProductAdapter productAdapter;
    private List<NoBillBeanOut.DataBean.BomResultBean.BomListBean> mlist = new ArrayList<>();
    private View layout;

    public interface PriorityListener {
        void setActivityText();
    }

    public SubCodeDialog(final Context context, int theme, List<NoBillBeanOut.DataBean.BomResultBean.BomListBean> list, PriorityListener priorityListener) {
        super(context, theme);
        layout = View.inflate(context, R.layout.dialog_sc, null);
        setContentView(layout);
        mContext = context;
        mlist = list;
        listener = priorityListener;
        ivexit = (ImageView) layout.findViewById(R.id.ivexit);
        ivexit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

        refreshLayout = (SmartRefreshLayout) layout.findViewById(R.id.refreshLayout);
        refreshLayout.setEnableRefresh(false);
        refreshLayout.setEnableHeaderTranslationContent(false);
        listView = (ListView) layout.findViewById(R.id.listview);
        productAdapter = new ProductAdapter(context,mlist);
        listView.setAdapter(productAdapter);
    }

    public void updateData(List<NoBillBeanOut.DataBean.BomResultBean.BomListBean> list){
        mlist.clear();
        mlist.addAll(list);
        productAdapter.notifyDataSetChanged();
    }

    @Override
    public void show() {
        PDApp.scanfsc = false;
        super.show();
    }


    @Override
    public void dismiss() {
        mlist=null;
        PDApp.scanfsc = true;
        super.dismiss();
    }
}


